﻿@namespace BootstrapBlazor.Components
@typeparam TValue
@inherits BootstrapInputBase<string>

<BootstrapInputGroup>
    @if (IsShowLabel)
    {
        <BootstrapLabel required="@Required" for="@Id" ShowLabelTooltip="ShowLabelTooltip" Value="@DisplayText" />
    }
    <div class="@ClassString" @ref="QuickSearchElement">
        <input @attributes="AdditionalAttributes" id="@Id" class="@ClassName" autocomplete="off" type="@Type" placeholder="@PlaceHolder" disabled="@Disabled" @bind-value="@CurrentValueAsString" @bind-value:event="oninput" @onblur="OnBlur" @onkeyup="OnKeyUp" @ref="FocusElement" />
        <i class="fa fa-fw fa-spinner fa-spin"></i>
        <div class="select-dropdown">
            <ul class="dropdown-list">
                @if (FilterItems.Any())
                {
                    @foreach (var item in FilterItems)
                    {
                        <li class="dropdown-item" @onmousedown="e => OnClickItem(item)">
                            <div>@SearchAccessor(item)</div>
                        </li>
                    }
                }
                else
                {
                    <li class="dropdown-item">@NoDataTip</li>
                }
            </ul>
        </div>
    </div>
    <CascadingValue Value="this" IsFixed="true">
        @ChildContent
    </CascadingValue>

    <Button Icon="fa fa-search" IsOutline OnClick="@OnClickWithoutRender"></Button>
</BootstrapInputGroup>